{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 给用户推荐标签"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 导入包\n",
    "import random\n",
    "import math\n",
    "import time\n",
    "from tqdm import tqdm"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 一. 通用函数定义"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 定义装饰器，监控运行时间\n",
    "def timmer(func):\n",
    "    def wrapper(*args, **kwargs):\n",
    "        start_time = time.time()\n",
    "        res = func(*args, **kwargs)\n",
    "        stop_time = time.time()\n",
    "        print('Func %s, run time: %s' % (func.__name__, stop_time - start_time))\n",
    "        return res\n",
    "    return wrapper"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 1. 数据处理相关\n",
    "Delicious-2k数据集\n",
    "1. load data\n",
    "2. split data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [],
   "source": [
    "class Dataset():\n",
    "    \n",
    "    def __init__(self, fp):\n",
    "        # fp: data file path\n",
    "        self.data = self.loadData(fp)\n",
    "    \n",
    "    @timmer\n",
    "    def loadData(self, fp):\n",
    "        data = [f.strip().split('\\t')[:3] for f in open(fp).readlines()[1:]]\n",
    "        return data\n",
    "    \n",
    "    @timmer\n",
    "    def splitData(self, M, k, seed=1):\n",
    "        '''\n",
    "        :params: data, 加载的所有(user, item)数据条目\n",
    "        :params: M, 划分的数目，最后需要取M折的平均\n",
    "        :params: k, 本次是第几次划分，k~[0, M)\n",
    "        :params: seed, random的种子数，对于不同的k应设置成一样的\n",
    "        :return: train, test\n",
    "        '''\n",
    "        # 按照(user, item)作为key进行划分\n",
    "        train, test = [], []\n",
    "        random.seed(seed)\n",
    "        for user, item, tag in self.data:\n",
    "            # 这里与书中的不一致，本人认为取M-1较为合理，因randint是左右都覆盖的\n",
    "            if random.randint(0, M-1) == k:  \n",
    "                test.append((user, item, tag))\n",
    "            else:\n",
    "                train.append((user, item, tag))\n",
    "\n",
    "        # 处理成字典的形式，user->set(items)\n",
    "        def convert_dict(data):\n",
    "            data_dict = {}\n",
    "            for user, item, tag in data:\n",
    "                if user not in data_dict:\n",
    "                    data_dict[user] = {}\n",
    "                if item not in data_dict[user]:\n",
    "                    data_dict[user][item] = set()\n",
    "                data_dict[user][item].add(tag)\n",
    "            for user in data_dict:\n",
    "                for item in data_dict[user]:\n",
    "                    data_dict[user][item] = list(data_dict[user][item])\n",
    "            return data_dict\n",
    "\n",
    "        return convert_dict(train), convert_dict(test)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 2. 评价指标\n",
    "1. Precision\n",
    "2. Recall\n",
    "3. Coverage\n",
    "4. Diversity\n",
    "5. Popularity(Novelty)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "class Metric():\n",
    "    \n",
    "    def __init__(self, train, test, GetRecommendation):\n",
    "        '''\n",
    "        :params: train, 训练数据\n",
    "        :params: test, 测试数据\n",
    "        :params: GetRecommendation, 为某个用户获取推荐物品的接口函数\n",
    "        '''\n",
    "        self.train = train\n",
    "        self.test = test\n",
    "        self.GetRecommendation = GetRecommendation\n",
    "        self.recs = self.getRec()\n",
    "        \n",
    "    # 为test中的每个用户进行推荐\n",
    "    def getRec(self):\n",
    "        recs = {}\n",
    "        for user in self.test:\n",
    "            recs[user] = {}\n",
    "            for item in self.test[user]:\n",
    "                rank = self.GetRecommendation(user, item)\n",
    "                recs[user][item] = rank\n",
    "        return recs\n",
    "        \n",
    "    # 定义精确率指标计算方式\n",
    "    def precision(self):\n",
    "        all, hit = 0, 0\n",
    "        for user in self.test:\n",
    "            for item in self.test[user]:\n",
    "                test_tags = set(self.test[user][item])\n",
    "                rank = self.recs[user][item]\n",
    "                for tag, score in rank:\n",
    "                    if tag in test_tags:\n",
    "                        hit += 1\n",
    "                all += len(rank)\n",
    "        return round(hit / all * 100, 2)\n",
    "    \n",
    "    # 定义召回率指标计算方式\n",
    "    def recall(self):\n",
    "        all, hit = 0, 0\n",
    "        for user in self.test:\n",
    "            for item in self.test[user]:\n",
    "                test_tags = set(self.test[user][item])\n",
    "                rank = self.recs[user][item]\n",
    "                for tag, score in rank:\n",
    "                    if tag in test_tags:\n",
    "                        hit += 1\n",
    "                all += len(test_tags)\n",
    "        return round(hit / all * 100, 2)\n",
    "    \n",
    "    def eval(self):\n",
    "        metric = {'Precision': self.precision(),\n",
    "                  'Recall': self.recall()}\n",
    "        print('Metric:', metric)\n",
    "        return metric"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 二. 算法实现\n",
    "1. Popular\n",
    "2. UserPopular\n",
    "3. ItemPopular\n",
    "4. HybridPopular"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 1. 推荐热门标签\n",
    "def Popular(train, N):\n",
    "    '''\n",
    "    :params: train, 训练数据集\n",
    "    :params: N, 超参数，设置取TopN推荐物品数目\n",
    "    :return: GetRecommendation，推荐接口函数\n",
    "    '''\n",
    "    # 统计tags\n",
    "    tags = {}\n",
    "    for user in train:\n",
    "        for item in train[user]:\n",
    "            for tag in train[user][item]:\n",
    "                if tag not in tags:\n",
    "                    tags[tag] = 0\n",
    "                tags[tag] += 1\n",
    "    tags = list(sorted(tags.items(), key=lambda x: x[1], reverse=True))[:N]\n",
    "    \n",
    "    def GetRecommendation(user, item):\n",
    "        return tags\n",
    "    \n",
    "    return GetRecommendation"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 2. 推荐用户最热门的标签\n",
    "def UserPopular(train, N):\n",
    "    '''\n",
    "    :params: train, 训练数据集\n",
    "    :params: N, 超参数，设置取TopN推荐物品数目\n",
    "    :return: GetRecommendation，推荐接口函数\n",
    "    '''\n",
    "    # 统计user_tags\n",
    "    user_tags = {}\n",
    "    for user in train:\n",
    "        user_tags[user] = {}\n",
    "        for item in train[user]:\n",
    "            for tag in train[user][item]:\n",
    "                if tag not in user_tags[user]:\n",
    "                    user_tags[user][tag] = 0\n",
    "                user_tags[user][tag] += 1\n",
    "    user_tags = {k: list(sorted(v.items(), key=lambda x: x[1], reverse=True)) \n",
    "                 for k, v in user_tags.items()}\n",
    "    \n",
    "    def GetRecommendation(user, item):\n",
    "        return user_tags[user][:N] if user in user_tags else []\n",
    "    \n",
    "    return GetRecommendation"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 3. 推荐物品最热门的标签\n",
    "def ItemPopular(train, N):\n",
    "    '''\n",
    "    :params: train, 训练数据集\n",
    "    :params: N, 超参数，设置取TopN推荐物品数目\n",
    "    :return: GetRecommendation，推荐接口函数\n",
    "    '''\n",
    "    # 统计item_tags\n",
    "    item_tags = {}\n",
    "    for user in train:\n",
    "        for item in train[user]:\n",
    "            if item not in item_tags:\n",
    "                item_tags[item] = {}\n",
    "            for tag in train[user][item]:\n",
    "                if tag not in item_tags[item]:\n",
    "                    item_tags[item][tag] = 0\n",
    "                item_tags[item][tag] += 1\n",
    "    item_tags = {k: list(sorted(v.items(), key=lambda x: x[1], reverse=True)) \n",
    "                 for k, v in item_tags.items()}\n",
    "    \n",
    "    def GetRecommendation(user, item):\n",
    "        return item_tags[item][:N] if item in item_tags else []\n",
    "    \n",
    "    return GetRecommendation"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 4. 联合用户和物品进行推荐\n",
    "def HybridPopular(train, N, alpha):\n",
    "    '''\n",
    "    :params: train, 训练数据集\n",
    "    :params: N, 超参数，设置取TopN推荐物品数目\n",
    "    :params: alpha，超参数，设置用户和物品的融合比例\n",
    "    :return: GetRecommendation，推荐接口函数\n",
    "    '''\n",
    "\n",
    "    # 统计user_tags\n",
    "    user_tags = {}\n",
    "    for user in train:\n",
    "        user_tags[user] = {}\n",
    "        for item in train[user]:\n",
    "            for tag in train[user][item]:\n",
    "                if tag not in user_tags[user]:\n",
    "                    user_tags[user][tag] = 0\n",
    "                user_tags[user][tag] += 1\n",
    "                \n",
    "    # 统计item_tags\n",
    "    item_tags = {}\n",
    "    for user in train:\n",
    "        for item in train[user]:\n",
    "            if item not in item_tags:\n",
    "                item_tags[item] = {}\n",
    "            for tag in train[user][item]:\n",
    "                if tag not in item_tags[item]:\n",
    "                    item_tags[item][tag] = 0\n",
    "                item_tags[item][tag] += 1\n",
    "    \n",
    "    def GetRecommendation(user, item):\n",
    "        tag_score = {}\n",
    "        if user in user_tags:\n",
    "            max_user_tag = max(user_tags[user].values())\n",
    "            for tag in user_tags[user]:\n",
    "                if tag not in tag_score:\n",
    "                    tag_score[tag] = 0\n",
    "                tag_score[tag] += (1 - alpha) * user_tags[user][tag] / max_user_tag\n",
    "        if item in item_tags:\n",
    "            max_item_tag = max(item_tags[item].values())\n",
    "            for tag in item_tags[item]:\n",
    "                if tag not in tag_score:\n",
    "                    tag_score[tag] = 0\n",
    "                tag_score[tag] += alpha * item_tags[item][tag] / max_item_tag\n",
    "        return list(sorted(tag_score.items(), key=lambda x: x[1], reverse=True))[:N]\n",
    "    \n",
    "    return GetRecommendation"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 三. 实验\n",
    "1. Popular实验\n",
    "2. UserPopular实验\n",
    "3. ItemPopular实验\n",
    "4. HybridPopular实验\n",
    "\n",
    "M=10, N=10"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [],
   "source": [
    "class Experiment():\n",
    "    \n",
    "    def __init__(self, M, N, fp='../dataset/delicious-2k/user_taggedbookmarks.dat', rt='Popular'):\n",
    "        '''\n",
    "        :params: M, 进行多少次实验\n",
    "        :params: N, TopN推荐物品的个数\n",
    "        :params: fp, 数据文件路径\n",
    "        :params: rt, 推荐算法类型\n",
    "        '''\n",
    "        self.M = M\n",
    "        self.N = N\n",
    "        self.fp = fp\n",
    "        self.rt = rt\n",
    "        self.alg = {'Popular': Popular, 'UserPopular': UserPopular, \\\n",
    "                    'ItemPopular': ItemPopular, 'HybridPopular': HybridPopular}\n",
    "    \n",
    "    # 定义单次实验\n",
    "    @timmer\n",
    "    def worker(self, train, test, **kwargs):\n",
    "        '''\n",
    "        :params: train, 训练数据集\n",
    "        :params: test, 测试数据集\n",
    "        :return: 各指标的值\n",
    "        '''\n",
    "        getRecommendation = self.alg[self.rt](train, self.N, **kwargs)\n",
    "        metric = Metric(train, test, getRecommendation)\n",
    "        return metric.eval()\n",
    "    \n",
    "    # 多次实验取平均\n",
    "    @timmer\n",
    "    def run(self, **kwargs):\n",
    "        metrics = {'Precision': 0, 'Recall': 0}\n",
    "        dataset = Dataset(self.fp)\n",
    "        for ii in range(self.M):\n",
    "            train, test = dataset.splitData(self.M, ii)\n",
    "            print('Experiment {}:'.format(ii))\n",
    "            metric = self.worker(train, test, **kwargs)\n",
    "            metrics = {k: metrics[k]+metric[k] for k in metrics}\n",
    "        metrics = {k: metrics[k] / self.M for k in metrics}\n",
    "        print('Average Result (M={}, N={}): {}'.format(\\\n",
    "                              self.M, self.N, metrics))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {
    "collapsed": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Func loadData, run time: 0.7870762348175049\n",
      "Func splitData, run time: 1.234386920928955\n",
      "Experiment 0:\n",
      "Metric: {'Precision': 0.87, 'Recall': 6.79}\n",
      "Func worker, run time: 0.26900410652160645\n",
      "Func splitData, run time: 1.0280041694641113\n",
      "Experiment 1:\n",
      "Metric: {'Precision': 0.83, 'Recall': 6.52}\n",
      "Func worker, run time: 0.19060897827148438\n",
      "Func splitData, run time: 1.0345518589019775\n",
      "Experiment 2:\n",
      "Metric: {'Precision': 0.84, 'Recall': 6.52}\n",
      "Func worker, run time: 0.20136189460754395\n",
      "Func splitData, run time: 1.0786409378051758\n",
      "Experiment 3:\n",
      "Metric: {'Precision': 0.84, 'Recall': 6.6}\n",
      "Func worker, run time: 0.19781804084777832\n",
      "Func splitData, run time: 1.1649599075317383\n",
      "Experiment 4:\n",
      "Metric: {'Precision': 0.85, 'Recall': 6.7}\n",
      "Func worker, run time: 0.19120001792907715\n",
      "Func splitData, run time: 1.0572938919067383\n",
      "Experiment 5:\n",
      "Metric: {'Precision': 0.83, 'Recall': 6.52}\n",
      "Func worker, run time: 0.20640897750854492\n",
      "Func splitData, run time: 0.8927929401397705\n",
      "Experiment 6:\n",
      "Metric: {'Precision': 0.88, 'Recall': 6.88}\n",
      "Func worker, run time: 0.18125414848327637\n",
      "Func splitData, run time: 1.024669885635376\n",
      "Experiment 7:\n",
      "Metric: {'Precision': 0.8, 'Recall': 6.27}\n",
      "Func worker, run time: 0.18497800827026367\n",
      "Func splitData, run time: 1.035869836807251\n",
      "Experiment 8:\n",
      "Metric: {'Precision': 0.84, 'Recall': 6.57}\n",
      "Func worker, run time: 0.20566082000732422\n",
      "Func splitData, run time: 1.166532039642334\n",
      "Experiment 9:\n",
      "Metric: {'Precision': 0.86, 'Recall': 6.7}\n",
      "Func worker, run time: 0.22189784049987793\n",
      "Average Result (M=10, N=10): {'Precision': 0.844, 'Recall': 6.607000000000001}\n",
      "Func run, run time: 13.749655961990356\n"
     ]
    }
   ],
   "source": [
    "# 1. Popular实验\n",
    "M, N = 10, 10\n",
    "exp = Experiment(M, N, rt='Popular')\n",
    "exp.run()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {
    "collapsed": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Func loadData, run time: 0.6694128513336182\n",
      "Func splitData, run time: 1.1229050159454346\n",
      "Experiment 0:\n",
      "Metric: {'Precision': 3.2, 'Recall': 24.96}\n",
      "Func worker, run time: 0.29575133323669434\n",
      "Func splitData, run time: 1.0629141330718994\n",
      "Experiment 1:\n",
      "Metric: {'Precision': 3.19, 'Recall': 24.88}\n",
      "Func worker, run time: 0.3048582077026367\n",
      "Func splitData, run time: 1.0542120933532715\n",
      "Experiment 2:\n",
      "Metric: {'Precision': 3.18, 'Recall': 24.69}\n",
      "Func worker, run time: 0.29949402809143066\n",
      "Func splitData, run time: 0.9658150672912598\n",
      "Experiment 3:\n",
      "Metric: {'Precision': 3.19, 'Recall': 24.84}\n",
      "Func worker, run time: 0.4243886470794678\n",
      "Func splitData, run time: 0.962958812713623\n",
      "Experiment 4:\n",
      "Metric: {'Precision': 3.17, 'Recall': 24.79}\n",
      "Func worker, run time: 0.4475588798522949\n",
      "Func splitData, run time: 0.9121999740600586\n",
      "Experiment 5:\n",
      "Metric: {'Precision': 3.12, 'Recall': 24.33}\n",
      "Func worker, run time: 0.46161675453186035\n",
      "Func splitData, run time: 0.9740099906921387\n",
      "Experiment 6:\n",
      "Metric: {'Precision': 3.17, 'Recall': 24.74}\n",
      "Func worker, run time: 0.4318516254425049\n",
      "Func splitData, run time: 0.8616311550140381\n",
      "Experiment 7:\n",
      "Metric: {'Precision': 3.13, 'Recall': 24.43}\n",
      "Func worker, run time: 0.4322950839996338\n",
      "Func splitData, run time: 0.8580801486968994\n",
      "Experiment 8:\n",
      "Metric: {'Precision': 3.17, 'Recall': 24.65}\n",
      "Func worker, run time: 0.42772817611694336\n",
      "Func splitData, run time: 0.8563971519470215\n",
      "Experiment 9:\n",
      "Metric: {'Precision': 3.17, 'Recall': 24.64}\n",
      "Func worker, run time: 0.43137383460998535\n",
      "Average Result (M=10, N=10): {'Precision': 3.1689999999999996, 'Recall': 24.695000000000004}\n",
      "Func run, run time: 14.44516921043396\n"
     ]
    }
   ],
   "source": [
    "# 2. UserPopular实验\n",
    "M, N = 10, 10\n",
    "exp = Experiment(M, N, rt='UserPopular')\n",
    "exp.run()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {
    "collapsed": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Func loadData, run time: 0.555941104888916\n",
      "Func splitData, run time: 1.1046972274780273\n",
      "Experiment 0:\n",
      "Metric: {'Precision': 1.67, 'Recall': 8.19}\n",
      "Func worker, run time: 0.7694768905639648\n",
      "Func splitData, run time: 0.9527928829193115\n",
      "Experiment 1:\n",
      "Metric: {'Precision': 1.57, 'Recall': 7.66}\n",
      "Func worker, run time: 0.7398290634155273\n",
      "Func splitData, run time: 0.9173603057861328\n",
      "Experiment 2:\n",
      "Metric: {'Precision': 1.62, 'Recall': 7.9}\n",
      "Func worker, run time: 0.655925989151001\n",
      "Func splitData, run time: 1.093824863433838\n",
      "Experiment 3:\n",
      "Metric: {'Precision': 1.6, 'Recall': 7.77}\n",
      "Func worker, run time: 0.49861979484558105\n",
      "Func splitData, run time: 1.1611483097076416\n",
      "Experiment 4:\n",
      "Metric: {'Precision': 1.63, 'Recall': 7.97}\n",
      "Func worker, run time: 0.5834429264068604\n",
      "Func splitData, run time: 1.0758311748504639\n",
      "Experiment 5:\n",
      "Metric: {'Precision': 1.62, 'Recall': 7.95}\n",
      "Func worker, run time: 0.5447440147399902\n",
      "Func splitData, run time: 1.1658220291137695\n",
      "Experiment 6:\n",
      "Metric: {'Precision': 1.62, 'Recall': 7.92}\n",
      "Func worker, run time: 0.570044994354248\n",
      "Func splitData, run time: 1.09977388381958\n",
      "Experiment 7:\n",
      "Metric: {'Precision': 1.61, 'Recall': 7.88}\n",
      "Func worker, run time: 0.5018339157104492\n",
      "Func splitData, run time: 1.0852570533752441\n",
      "Experiment 8:\n",
      "Metric: {'Precision': 1.61, 'Recall': 7.83}\n",
      "Func worker, run time: 0.5137588977813721\n",
      "Func splitData, run time: 1.1302859783172607\n",
      "Experiment 9:\n",
      "Metric: {'Precision': 1.59, 'Recall': 7.74}\n",
      "Func worker, run time: 0.6344318389892578\n",
      "Average Result (M=10, N=10): {'Precision': 1.614, 'Recall': 7.881}\n",
      "Func run, run time: 17.594825983047485\n"
     ]
    }
   ],
   "source": [
    "# 3. ItemPopular实验\n",
    "M, N = 10, 10\n",
    "exp = Experiment(M, N, rt='ItemPopular')\n",
    "exp.run()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {
    "collapsed": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "alpha = 0.0\n",
      "Func loadData, run time: 0.8270349502563477\n",
      "Func splitData, run time: 1.1357169151306152\n",
      "Experiment 0:\n",
      "Metric: {'Precision': 3.2, 'Recall': 24.98}\n",
      "Func worker, run time: 3.6687381267547607\n",
      "Func splitData, run time: 1.313784122467041\n",
      "Experiment 1:\n",
      "Metric: {'Precision': 3.19, 'Recall': 24.89}\n",
      "Func worker, run time: 3.9108307361602783\n",
      "Func splitData, run time: 1.080482006072998\n",
      "Experiment 2:\n",
      "Metric: {'Precision': 3.17, 'Recall': 24.7}\n",
      "Func worker, run time: 3.9596028327941895\n",
      "Func splitData, run time: 1.113774061203003\n",
      "Experiment 3:\n",
      "Metric: {'Precision': 3.19, 'Recall': 24.86}\n",
      "Func worker, run time: 3.9999098777770996\n",
      "Func splitData, run time: 1.1503219604492188\n",
      "Experiment 4:\n",
      "Metric: {'Precision': 3.17, 'Recall': 24.8}\n",
      "Func worker, run time: 3.866776943206787\n",
      "Func splitData, run time: 0.9508001804351807\n",
      "Experiment 5:\n",
      "Metric: {'Precision': 3.12, 'Recall': 24.35}\n",
      "Func worker, run time: 4.116667985916138\n",
      "Func splitData, run time: 0.9126389026641846\n",
      "Experiment 6:\n",
      "Metric: {'Precision': 3.16, 'Recall': 24.75}\n",
      "Func worker, run time: 4.2959370613098145\n",
      "Func splitData, run time: 0.9400320053100586\n",
      "Experiment 7:\n",
      "Metric: {'Precision': 3.13, 'Recall': 24.45}\n",
      "Func worker, run time: 4.016885042190552\n",
      "Func splitData, run time: 0.9569549560546875\n",
      "Experiment 8:\n",
      "Metric: {'Precision': 3.16, 'Recall': 24.66}\n",
      "Func worker, run time: 4.140321969985962\n",
      "Func splitData, run time: 0.9315330982208252\n",
      "Experiment 9:\n",
      "Metric: {'Precision': 3.17, 'Recall': 24.66}\n",
      "Func worker, run time: 3.96396803855896\n",
      "Average Result (M=10, N=10): {'Precision': 3.1659999999999995, 'Recall': 24.71}\n",
      "Func run, run time: 51.46743392944336\n",
      "alpha = 0.1\n",
      "Func loadData, run time: 0.5897848606109619\n",
      "Func splitData, run time: 1.2940878868103027\n",
      "Experiment 0:\n",
      "Metric: {'Precision': 3.16, 'Recall': 24.71}\n",
      "Func worker, run time: 4.220802068710327\n",
      "Func splitData, run time: 1.119277000427246\n",
      "Experiment 1:\n",
      "Metric: {'Precision': 3.16, 'Recall': 24.67}\n",
      "Func worker, run time: 3.690171003341675\n",
      "Func splitData, run time: 1.1244220733642578\n",
      "Experiment 2:\n",
      "Metric: {'Precision': 3.15, 'Recall': 24.52}\n",
      "Func worker, run time: 3.741908073425293\n",
      "Func splitData, run time: 1.0858471393585205\n",
      "Experiment 3:\n",
      "Metric: {'Precision': 3.15, 'Recall': 24.57}\n",
      "Func worker, run time: 3.828856945037842\n",
      "Func splitData, run time: 0.9331462383270264\n",
      "Experiment 4:\n",
      "Metric: {'Precision': 3.15, 'Recall': 24.68}\n",
      "Func worker, run time: 3.770294189453125\n",
      "Func splitData, run time: 0.881289005279541\n",
      "Experiment 5:\n",
      "Metric: {'Precision': 3.09, 'Recall': 24.13}\n",
      "Func worker, run time: 3.8148388862609863\n",
      "Func splitData, run time: 0.9065887928009033\n",
      "Experiment 6:\n",
      "Metric: {'Precision': 3.13, 'Recall': 24.52}\n",
      "Func worker, run time: 3.847368001937866\n",
      "Func splitData, run time: 0.8994863033294678\n",
      "Experiment 7:\n",
      "Metric: {'Precision': 3.09, 'Recall': 24.18}\n",
      "Func worker, run time: 3.8750672340393066\n",
      "Func splitData, run time: 0.9352071285247803\n",
      "Experiment 8:\n",
      "Metric: {'Precision': 3.14, 'Recall': 24.45}\n",
      "Func worker, run time: 3.980964183807373\n",
      "Func splitData, run time: 0.8821008205413818\n",
      "Experiment 9:\n",
      "Metric: {'Precision': 3.13, 'Recall': 24.37}\n",
      "Func worker, run time: 3.780784845352173\n",
      "Average Result (M=10, N=10): {'Precision': 3.135, 'Recall': 24.48}\n",
      "Func run, run time: 49.395665884017944\n",
      "alpha = 0.2\n",
      "Func loadData, run time: 0.5564239025115967\n",
      "Func splitData, run time: 1.0819451808929443\n",
      "Experiment 0:\n",
      "Metric: {'Precision': 3.09, 'Recall': 24.13}\n",
      "Func worker, run time: 3.7844419479370117\n",
      "Func splitData, run time: 1.1305460929870605\n",
      "Experiment 1:\n",
      "Metric: {'Precision': 3.08, 'Recall': 24.05}\n",
      "Func worker, run time: 3.8170173168182373\n",
      "Func splitData, run time: 0.8823709487915039\n",
      "Experiment 2:\n",
      "Metric: {'Precision': 3.07, 'Recall': 23.88}\n",
      "Func worker, run time: 3.8645858764648438\n",
      "Func splitData, run time: 0.926703929901123\n",
      "Experiment 3:\n",
      "Metric: {'Precision': 3.06, 'Recall': 23.85}\n",
      "Func worker, run time: 3.8203530311584473\n",
      "Func splitData, run time: 0.8779711723327637\n",
      "Experiment 4:\n",
      "Metric: {'Precision': 3.07, 'Recall': 24.07}\n",
      "Func worker, run time: 4.0470640659332275\n",
      "Func splitData, run time: 0.8845350742340088\n",
      "Experiment 5:\n",
      "Metric: {'Precision': 3.04, 'Recall': 23.76}\n",
      "Func worker, run time: 3.8835208415985107\n",
      "Func splitData, run time: 0.8999407291412354\n",
      "Experiment 6:\n",
      "Metric: {'Precision': 3.06, 'Recall': 23.94}\n",
      "Func worker, run time: 3.8781838417053223\n",
      "Func splitData, run time: 0.8658223152160645\n",
      "Experiment 7:\n",
      "Metric: {'Precision': 3.02, 'Recall': 23.59}\n",
      "Func worker, run time: 3.9182791709899902\n",
      "Func splitData, run time: 0.8931410312652588\n",
      "Experiment 8:\n",
      "Metric: {'Precision': 3.06, 'Recall': 23.88}\n",
      "Func worker, run time: 3.91605281829834\n",
      "Func splitData, run time: 0.9485352039337158\n",
      "Experiment 9:\n",
      "Metric: {'Precision': 3.05, 'Recall': 23.75}\n",
      "Func worker, run time: 3.9514670372009277\n",
      "Average Result (M=10, N=10): {'Precision': 3.0599999999999996, 'Recall': 23.889999999999997}\n",
      "Func run, run time: 49.03358316421509\n",
      "alpha = 0.3\n",
      "Func loadData, run time: 0.8165087699890137\n",
      "Func splitData, run time: 1.1548380851745605\n",
      "Experiment 0:\n",
      "Metric: {'Precision': 2.99, 'Recall': 23.33}\n",
      "Func worker, run time: 3.9186530113220215\n",
      "Func splitData, run time: 1.1145899295806885\n",
      "Experiment 1:\n",
      "Metric: {'Precision': 2.98, 'Recall': 23.23}\n",
      "Func worker, run time: 3.880518913269043\n",
      "Func splitData, run time: 0.9590201377868652\n",
      "Experiment 2:\n",
      "Metric: {'Precision': 2.98, 'Recall': 23.18}\n",
      "Func worker, run time: 4.014327049255371\n",
      "Func splitData, run time: 0.9428629875183105\n",
      "Experiment 3:\n",
      "Metric: {'Precision': 2.96, 'Recall': 23.07}\n",
      "Func worker, run time: 4.099957704544067\n",
      "Func splitData, run time: 0.945389986038208\n",
      "Experiment 4:\n",
      "Metric: {'Precision': 2.98, 'Recall': 23.37}\n",
      "Func worker, run time: 3.903257131576538\n",
      "Func splitData, run time: 0.8871619701385498\n",
      "Experiment 5:\n",
      "Metric: {'Precision': 2.95, 'Recall': 23.01}\n",
      "Func worker, run time: 4.016380310058594\n",
      "Func splitData, run time: 0.9477517604827881\n",
      "Experiment 6:\n",
      "Metric: {'Precision': 2.97, 'Recall': 23.2}\n",
      "Func worker, run time: 4.101273059844971\n",
      "Func splitData, run time: 0.9239673614501953\n",
      "Experiment 7:\n",
      "Metric: {'Precision': 2.93, 'Recall': 22.92}\n",
      "Func worker, run time: 4.01638388633728\n",
      "Func splitData, run time: 1.129809856414795\n",
      "Experiment 8:\n",
      "Metric: {'Precision': 2.97, 'Recall': 23.17}\n",
      "Func worker, run time: 4.296221971511841\n",
      "Func splitData, run time: 1.0508511066436768\n",
      "Experiment 9:\n",
      "Metric: {'Precision': 2.96, 'Recall': 23.06}\n",
      "Func worker, run time: 4.31338906288147\n",
      "Average Result (M=10, N=10): {'Precision': 2.9669999999999996, 'Recall': 23.154000000000003}\n",
      "Func run, run time: 51.64158391952515\n",
      "alpha = 0.4\n",
      "Func loadData, run time: 0.5854520797729492\n",
      "Func splitData, run time: 1.2064447402954102\n",
      "Experiment 0:\n",
      "Metric: {'Precision': 2.9, 'Recall': 22.66}\n",
      "Func worker, run time: 3.82174015045166\n",
      "Func splitData, run time: 1.109299898147583\n",
      "Experiment 1:\n",
      "Metric: {'Precision': 2.89, 'Recall': 22.59}\n",
      "Func worker, run time: 3.7054030895233154\n",
      "Func splitData, run time: 1.0969369411468506\n",
      "Experiment 2:\n",
      "Metric: {'Precision': 2.9, 'Recall': 22.58}\n",
      "Func worker, run time: 3.6588618755340576\n",
      "Func splitData, run time: 1.0210728645324707\n",
      "Experiment 3:\n",
      "Metric: {'Precision': 2.88, 'Recall': 22.49}\n",
      "Func worker, run time: 4.334802150726318\n",
      "Func splitData, run time: 0.9911270141601562\n",
      "Experiment 4:\n",
      "Metric: {'Precision': 2.89, 'Recall': 22.63}\n",
      "Func worker, run time: 3.9276959896087646\n",
      "Func splitData, run time: 0.8923721313476562\n",
      "Experiment 5:\n",
      "Metric: {'Precision': 2.88, 'Recall': 22.5}\n",
      "Func worker, run time: 3.918529987335205\n",
      "Func splitData, run time: 0.8772850036621094\n",
      "Experiment 6:\n",
      "Metric: {'Precision': 2.89, 'Recall': 22.64}\n",
      "Func worker, run time: 4.415400981903076\n",
      "Func splitData, run time: 0.9515841007232666\n",
      "Experiment 7:\n",
      "Metric: {'Precision': 2.86, 'Recall': 22.31}\n",
      "Func worker, run time: 3.962172269821167\n",
      "Func splitData, run time: 0.9239819049835205\n",
      "Experiment 8:\n",
      "Metric: {'Precision': 2.89, 'Recall': 22.53}\n",
      "Func worker, run time: 4.088367938995361\n",
      "Func splitData, run time: 0.9344871044158936\n",
      "Experiment 9:\n",
      "Metric: {'Precision': 2.89, 'Recall': 22.48}\n",
      "Func worker, run time: 4.000338077545166\n",
      "Average Result (M=10, N=10): {'Precision': 2.887, 'Recall': 22.540999999999997}\n",
      "Func run, run time: 50.62652516365051\n",
      "alpha = 0.5\n",
      "Func loadData, run time: 0.6036858558654785\n",
      "Func splitData, run time: 1.1832058429718018\n",
      "Experiment 0:\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Metric: {'Precision': 2.83, 'Recall': 22.12}\n",
      "Func worker, run time: 3.846303939819336\n",
      "Func splitData, run time: 1.1365282535552979\n",
      "Experiment 1:\n",
      "Metric: {'Precision': 2.82, 'Recall': 21.99}\n",
      "Func worker, run time: 3.859900951385498\n",
      "Func splitData, run time: 0.9495680332183838\n",
      "Experiment 2:\n",
      "Metric: {'Precision': 2.83, 'Recall': 22.04}\n",
      "Func worker, run time: 4.079281806945801\n",
      "Func splitData, run time: 0.9861047267913818\n",
      "Experiment 3:\n",
      "Metric: {'Precision': 2.83, 'Recall': 22.06}\n",
      "Func worker, run time: 4.394114017486572\n",
      "Func splitData, run time: 1.0009009838104248\n",
      "Experiment 4:\n",
      "Metric: {'Precision': 2.82, 'Recall': 22.1}\n",
      "Func worker, run time: 4.027346134185791\n",
      "Func splitData, run time: 0.8993139266967773\n",
      "Experiment 5:\n",
      "Metric: {'Precision': 2.81, 'Recall': 21.98}\n",
      "Func worker, run time: 4.053209066390991\n",
      "Func splitData, run time: 0.9647109508514404\n",
      "Experiment 6:\n",
      "Metric: {'Precision': 2.83, 'Recall': 22.13}\n",
      "Func worker, run time: 4.376596927642822\n",
      "Func splitData, run time: 1.0014677047729492\n",
      "Experiment 7:\n",
      "Metric: {'Precision': 2.78, 'Recall': 21.74}\n",
      "Func worker, run time: 4.266858816146851\n",
      "Func splitData, run time: 0.924774169921875\n",
      "Experiment 8:\n",
      "Metric: {'Precision': 2.81, 'Recall': 21.9}\n",
      "Func worker, run time: 3.9737420082092285\n",
      "Func splitData, run time: 0.8944978713989258\n",
      "Experiment 9:\n",
      "Metric: {'Precision': 2.82, 'Recall': 21.92}\n",
      "Func worker, run time: 3.682781934738159\n",
      "Average Result (M=10, N=10): {'Precision': 2.8180000000000005, 'Recall': 21.998}\n",
      "Func run, run time: 51.33020997047424\n",
      "alpha = 0.6\n",
      "Func loadData, run time: 0.7814671993255615\n",
      "Func splitData, run time: 1.1311962604522705\n",
      "Experiment 0:\n",
      "Metric: {'Precision': 2.81, 'Recall': 21.99}\n",
      "Func worker, run time: 3.6779329776763916\n",
      "Func splitData, run time: 1.0877008438110352\n",
      "Experiment 1:\n",
      "Metric: {'Precision': 2.8, 'Recall': 21.87}\n",
      "Func worker, run time: 3.7011940479278564\n",
      "Func splitData, run time: 0.931542158126831\n",
      "Experiment 2:\n",
      "Metric: {'Precision': 2.83, 'Recall': 22.02}\n",
      "Func worker, run time: 4.184109926223755\n",
      "Func splitData, run time: 0.9873087406158447\n",
      "Experiment 3:\n",
      "Metric: {'Precision': 2.81, 'Recall': 21.95}\n",
      "Func worker, run time: 4.34235692024231\n",
      "Func splitData, run time: 0.9976329803466797\n",
      "Experiment 4:\n",
      "Metric: {'Precision': 2.81, 'Recall': 21.99}\n",
      "Func worker, run time: 4.107128858566284\n",
      "Func splitData, run time: 1.0260448455810547\n",
      "Experiment 5:\n",
      "Metric: {'Precision': 2.8, 'Recall': 21.87}\n",
      "Func worker, run time: 4.346803903579712\n",
      "Func splitData, run time: 0.9875109195709229\n",
      "Experiment 6:\n",
      "Metric: {'Precision': 2.81, 'Recall': 21.97}\n",
      "Func worker, run time: 4.095118045806885\n",
      "Func splitData, run time: 0.954246997833252\n",
      "Experiment 7:\n",
      "Metric: {'Precision': 2.77, 'Recall': 21.64}\n",
      "Func worker, run time: 4.133518934249878\n",
      "Func splitData, run time: 0.9359958171844482\n",
      "Experiment 8:\n",
      "Metric: {'Precision': 2.79, 'Recall': 21.78}\n",
      "Func worker, run time: 4.088289976119995\n",
      "Func splitData, run time: 0.9729337692260742\n",
      "Experiment 9:\n",
      "Metric: {'Precision': 2.8, 'Recall': 21.83}\n",
      "Func worker, run time: 4.133095979690552\n",
      "Average Result (M=10, N=10): {'Precision': 2.803, 'Recall': 21.891000000000002}\n",
      "Func run, run time: 51.847046852111816\n",
      "alpha = 0.7\n",
      "Func loadData, run time: 0.6439578533172607\n",
      "Func splitData, run time: 1.2230210304260254\n",
      "Experiment 0:\n",
      "Metric: {'Precision': 2.8, 'Recall': 21.87}\n",
      "Func worker, run time: 3.8913540840148926\n",
      "Func splitData, run time: 1.1245911121368408\n",
      "Experiment 1:\n",
      "Metric: {'Precision': 2.79, 'Recall': 21.81}\n",
      "Func worker, run time: 3.9031801223754883\n",
      "Func splitData, run time: 1.241105079650879\n",
      "Experiment 2:\n",
      "Metric: {'Precision': 2.81, 'Recall': 21.87}\n",
      "Func worker, run time: 3.9086101055145264\n",
      "Func splitData, run time: 0.9072818756103516\n",
      "Experiment 3:\n",
      "Metric: {'Precision': 2.79, 'Recall': 21.74}\n",
      "Func worker, run time: 4.126950740814209\n",
      "Func splitData, run time: 0.9839358329772949\n",
      "Experiment 4:\n",
      "Metric: {'Precision': 2.79, 'Recall': 21.85}\n",
      "Func worker, run time: 4.147830009460449\n",
      "Func splitData, run time: 0.9406859874725342\n",
      "Experiment 5:\n",
      "Metric: {'Precision': 2.8, 'Recall': 21.84}\n",
      "Func worker, run time: 4.09603214263916\n",
      "Func splitData, run time: 0.9855873584747314\n",
      "Experiment 6:\n",
      "Metric: {'Precision': 2.79, 'Recall': 21.83}\n",
      "Func worker, run time: 4.132368326187134\n",
      "Func splitData, run time: 0.9442930221557617\n",
      "Experiment 7:\n",
      "Metric: {'Precision': 2.77, 'Recall': 21.61}\n",
      "Func worker, run time: 4.14454984664917\n",
      "Func splitData, run time: 0.9878599643707275\n",
      "Experiment 8:\n",
      "Metric: {'Precision': 2.78, 'Recall': 21.67}\n",
      "Func worker, run time: 4.150234937667847\n",
      "Func splitData, run time: 0.9582130908966064\n",
      "Experiment 9:\n",
      "Metric: {'Precision': 2.79, 'Recall': 21.75}\n",
      "Func worker, run time: 4.084574937820435\n",
      "Average Result (M=10, N=10): {'Precision': 2.791, 'Recall': 21.784000000000002}\n",
      "Func run, run time: 51.78817391395569\n",
      "alpha = 0.8\n",
      "Func loadData, run time: 0.6539361476898193\n",
      "Func splitData, run time: 1.23051118850708\n",
      "Experiment 0:\n",
      "Metric: {'Precision': 2.79, 'Recall': 21.8}\n",
      "Func worker, run time: 3.9864609241485596\n",
      "Func splitData, run time: 1.1422462463378906\n",
      "Experiment 1:\n",
      "Metric: {'Precision': 2.78, 'Recall': 21.71}\n",
      "Func worker, run time: 3.915750026702881\n",
      "Func splitData, run time: 0.9693622589111328\n",
      "Experiment 2:\n",
      "Metric: {'Precision': 2.8, 'Recall': 21.79}\n",
      "Func worker, run time: 4.121142148971558\n",
      "Func splitData, run time: 0.9255979061126709\n",
      "Experiment 3:\n",
      "Metric: {'Precision': 2.78, 'Recall': 21.69}\n",
      "Func worker, run time: 4.081761598587036\n",
      "Func splitData, run time: 0.9528212547302246\n",
      "Experiment 4:\n",
      "Metric: {'Precision': 2.78, 'Recall': 21.77}\n",
      "Func worker, run time: 4.107932090759277\n",
      "Func splitData, run time: 0.9039068222045898\n",
      "Experiment 5:\n",
      "Metric: {'Precision': 2.79, 'Recall': 21.77}\n",
      "Func worker, run time: 4.103371858596802\n",
      "Func splitData, run time: 0.9776840209960938\n",
      "Experiment 6:\n",
      "Metric: {'Precision': 2.78, 'Recall': 21.77}\n",
      "Func worker, run time: 4.158017873764038\n",
      "Func splitData, run time: 0.9379229545593262\n",
      "Experiment 7:\n",
      "Metric: {'Precision': 2.76, 'Recall': 21.54}\n",
      "Func worker, run time: 4.1544189453125\n",
      "Func splitData, run time: 0.9832949638366699\n",
      "Experiment 8:\n",
      "Metric: {'Precision': 2.76, 'Recall': 21.55}\n",
      "Func worker, run time: 4.169132947921753\n",
      "Func splitData, run time: 0.9408540725708008\n",
      "Experiment 9:\n",
      "Metric: {'Precision': 2.78, 'Recall': 21.68}\n",
      "Func worker, run time: 3.8871219158172607\n",
      "Average Result (M=10, N=10): {'Precision': 2.78, 'Recall': 21.707}\n",
      "Func run, run time: 51.54830598831177\n",
      "alpha = 0.9\n",
      "Func loadData, run time: 1.0025537014007568\n",
      "Func splitData, run time: 1.333798885345459\n",
      "Experiment 0:\n",
      "Metric: {'Precision': 2.78, 'Recall': 21.72}\n",
      "Func worker, run time: 4.1268157958984375\n",
      "Func splitData, run time: 1.2158279418945312\n",
      "Experiment 1:\n",
      "Metric: {'Precision': 2.77, 'Recall': 21.64}\n",
      "Func worker, run time: 4.124691963195801\n",
      "Func splitData, run time: 0.9392058849334717\n",
      "Experiment 2:\n",
      "Metric: {'Precision': 2.79, 'Recall': 21.73}\n",
      "Func worker, run time: 4.153153896331787\n",
      "Func splitData, run time: 1.040349006652832\n",
      "Experiment 3:\n",
      "Metric: {'Precision': 2.78, 'Recall': 21.65}\n",
      "Func worker, run time: 4.2734057903289795\n",
      "Func splitData, run time: 0.9350490570068359\n",
      "Experiment 4:\n",
      "Metric: {'Precision': 2.77, 'Recall': 21.74}\n",
      "Func worker, run time: 4.1106908321380615\n",
      "Func splitData, run time: 0.9704811573028564\n",
      "Experiment 5:\n",
      "Metric: {'Precision': 2.78, 'Recall': 21.74}\n",
      "Func worker, run time: 4.073996067047119\n",
      "Func splitData, run time: 0.9093971252441406\n",
      "Experiment 6:\n",
      "Metric: {'Precision': 2.78, 'Recall': 21.71}\n",
      "Func worker, run time: 4.173330783843994\n",
      "Func splitData, run time: 0.950319766998291\n",
      "Experiment 7:\n",
      "Metric: {'Precision': 2.75, 'Recall': 21.5}\n",
      "Func worker, run time: 4.211034059524536\n",
      "Func splitData, run time: 0.9746339321136475\n",
      "Experiment 8:\n",
      "Metric: {'Precision': 2.76, 'Recall': 21.51}\n",
      "Func worker, run time: 4.386167049407959\n",
      "Func splitData, run time: 1.059217929840088\n",
      "Experiment 9:\n",
      "Metric: {'Precision': 2.78, 'Recall': 21.63}\n",
      "Func worker, run time: 4.3950629234313965\n",
      "Average Result (M=10, N=10): {'Precision': 2.774, 'Recall': 21.657}\n",
      "Func run, run time: 53.61407208442688\n",
      "alpha = 1.0\n",
      "Func loadData, run time: 0.759735107421875\n",
      "Func splitData, run time: 1.224877119064331\n",
      "Experiment 0:\n",
      "Metric: {'Precision': 1.82, 'Recall': 14.18}\n",
      "Func worker, run time: 3.729387044906616\n",
      "Func splitData, run time: 1.0924749374389648\n",
      "Experiment 1:\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Metric: {'Precision': 1.8, 'Recall': 14.09}\n",
      "Func worker, run time: 3.4529192447662354\n",
      "Func splitData, run time: 1.1971077919006348\n",
      "Experiment 2:\n",
      "Metric: {'Precision': 1.82, 'Recall': 14.17}\n",
      "Func worker, run time: 3.3798270225524902\n",
      "Func splitData, run time: 0.9837942123413086\n",
      "Experiment 3:\n",
      "Metric: {'Precision': 1.79, 'Recall': 13.97}\n",
      "Func worker, run time: 3.9176063537597656\n",
      "Func splitData, run time: 0.9464359283447266\n",
      "Experiment 4:\n",
      "Metric: {'Precision': 1.8, 'Recall': 14.13}\n",
      "Func worker, run time: 3.7294299602508545\n",
      "Func splitData, run time: 0.9589240550994873\n",
      "Experiment 5:\n",
      "Metric: {'Precision': 1.81, 'Recall': 14.16}\n",
      "Func worker, run time: 3.68717098236084\n",
      "Func splitData, run time: 0.9121508598327637\n",
      "Experiment 6:\n",
      "Metric: {'Precision': 1.82, 'Recall': 14.22}\n",
      "Func worker, run time: 3.720194101333618\n",
      "Func splitData, run time: 0.9417569637298584\n",
      "Experiment 7:\n",
      "Metric: {'Precision': 1.8, 'Recall': 14.05}\n",
      "Func worker, run time: 3.7353739738464355\n",
      "Func splitData, run time: 0.9648470878601074\n",
      "Experiment 8:\n",
      "Metric: {'Precision': 1.78, 'Recall': 13.9}\n",
      "Func worker, run time: 3.7211191654205322\n",
      "Func splitData, run time: 0.9093520641326904\n",
      "Experiment 9:\n",
      "Metric: {'Precision': 1.81, 'Recall': 14.08}\n",
      "Func worker, run time: 3.725862979888916\n",
      "Average Result (M=10, N=10): {'Precision': 1.8050000000000002, 'Recall': 14.094999999999999}\n",
      "Func run, run time: 47.9080491065979\n"
     ]
    }
   ],
   "source": [
    "# 4. HybridPopular实验\n",
    "M, N = 10, 10\n",
    "for alpha in range(0, 11):\n",
    "    alpha /= 10\n",
    "    print('alpha =', alpha)\n",
    "    exp = Experiment(M, N, rt='HybridPopular')\n",
    "    exp.run(alpha=alpha)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 四. 实验结果\n",
    "1. Popular实验\n",
    "\n",
    "    Running time: 13.749655961990356\n",
    "    \n",
    "    Average Result (M=10, N=10): {'Precision': 0.844, 'Recall': 6.607000000000001}\n",
    "Func run, run time: 13.749655961990356\n",
    "     \n",
    "2. UserPopular实验\n",
    "    \n",
    "    Running time: 14.44516921043396\n",
    "    \n",
    "    Average Result (M=10, N=10): {'Precision': 3.1689999999999996, 'Recall': 24.695000000000004}\n",
    "     \n",
    "3. ItemPopular实验\n",
    "    \n",
    "    Running time: 17.594825983047485\n",
    "    \n",
    "    Average Result (M=10, N=10): {'Precision': 1.614, 'Recall': 7.881}\n",
    "\n",
    "4. HybridPopular实验（因为此数据集里面的ItemPopular效果特别不好，所以随着alpha增大，效果越来越差）\n",
    "\n",
    "    alpha = 0.0\n",
    "    Average Result (M=10, N=10): {'Precision': 3.1659999999999995, 'Recall': 24.71}\n",
    "    \n",
    "    alpha = 0.1\n",
    "    Average Result (M=10, N=10): {'Precision': 3.135, 'Recall': 24.48}\n",
    "    \n",
    "    alpha = 0.2\n",
    "    Average Result (M=10, N=10): {'Precision': 3.0599999999999996, 'Recall': 23.889999999999997}\n",
    "    \n",
    "    alpha = 0.3\n",
    "    Average Result (M=10, N=10): {'Precision': 2.9669999999999996, 'Recall': 23.154000000000003}\n",
    "    \n",
    "    alpha = 0.4\n",
    "    Average Result (M=10, N=10): {'Precision': 2.887, 'Recall': 22.540999999999997}\n",
    "    \n",
    "    alpha = 0.5\n",
    "    Average Result (M=10, N=10): {'Precision': 2.8180000000000005, 'Recall': 21.998}\n",
    "    \n",
    "    alpha = 0.6\n",
    "    Average Result (M=10, N=10): {'Precision': 2.803, 'Recall': 21.891000000000002}\n",
    "    \n",
    "    alpha = 0.7\n",
    "    Average Result (M=10, N=10): {'Precision': 2.791, 'Recall': 21.784000000000002}\n",
    "    \n",
    "    alpha = 0.8\n",
    "    Average Result (M=10, N=10): {'Precision': 2.78, 'Recall': 21.707}\n",
    "    \n",
    "    alpha = 0.9\n",
    "    Average Result (M=10, N=10): {'Precision': 2.774, 'Recall': 21.657}\n",
    "    \n",
    "    alpha = 1.0\n",
    "    Average Result (M=10, N=10): {'Precision': 1.8050000000000002, 'Recall': 14.094999999999999}"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 五. 总结\n",
    "1. 运行结果与书中的结果很多都不相符，怀疑是数据集的原因，书中并没有提供数据集，之后还是要根据实际情况来调"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 附：运行日志（请双击看）\n",
    "\n",
    "1. Popular实验\n",
    "Func loadData, run time: 0.7870762348175049\n",
    "Func splitData, run time: 1.234386920928955\n",
    "Experiment 0:\n",
    "Metric: {'Precision': 0.87, 'Recall': 6.79}\n",
    "Func worker, run time: 0.26900410652160645\n",
    "Func splitData, run time: 1.0280041694641113\n",
    "Experiment 1:\n",
    "Metric: {'Precision': 0.83, 'Recall': 6.52}\n",
    "Func worker, run time: 0.19060897827148438\n",
    "Func splitData, run time: 1.0345518589019775\n",
    "Experiment 2:\n",
    "Metric: {'Precision': 0.84, 'Recall': 6.52}\n",
    "Func worker, run time: 0.20136189460754395\n",
    "Func splitData, run time: 1.0786409378051758\n",
    "Experiment 3:\n",
    "Metric: {'Precision': 0.84, 'Recall': 6.6}\n",
    "Func worker, run time: 0.19781804084777832\n",
    "Func splitData, run time: 1.1649599075317383\n",
    "Experiment 4:\n",
    "Metric: {'Precision': 0.85, 'Recall': 6.7}\n",
    "Func worker, run time: 0.19120001792907715\n",
    "Func splitData, run time: 1.0572938919067383\n",
    "Experiment 5:\n",
    "Metric: {'Precision': 0.83, 'Recall': 6.52}\n",
    "Func worker, run time: 0.20640897750854492\n",
    "Func splitData, run time: 0.8927929401397705\n",
    "Experiment 6:\n",
    "Metric: {'Precision': 0.88, 'Recall': 6.88}\n",
    "Func worker, run time: 0.18125414848327637\n",
    "Func splitData, run time: 1.024669885635376\n",
    "Experiment 7:\n",
    "Metric: {'Precision': 0.8, 'Recall': 6.27}\n",
    "Func worker, run time: 0.18497800827026367\n",
    "Func splitData, run time: 1.035869836807251\n",
    "Experiment 8:\n",
    "Metric: {'Precision': 0.84, 'Recall': 6.57}\n",
    "Func worker, run time: 0.20566082000732422\n",
    "Func splitData, run time: 1.166532039642334\n",
    "Experiment 9:\n",
    "Metric: {'Precision': 0.86, 'Recall': 6.7}\n",
    "Func worker, run time: 0.22189784049987793\n",
    "Average Result (M=10, N=10): {'Precision': 0.844, 'Recall': 6.607000000000001}\n",
    "Func run, run time: 13.749655961990356\n",
    "\n",
    "2. UserPopular实验\n",
    "Func loadData, run time: 0.6694128513336182\n",
    "Func splitData, run time: 1.1229050159454346\n",
    "Experiment 0:\n",
    "Metric: {'Precision': 3.2, 'Recall': 24.96}\n",
    "Func worker, run time: 0.29575133323669434\n",
    "Func splitData, run time: 1.0629141330718994\n",
    "Experiment 1:\n",
    "Metric: {'Precision': 3.19, 'Recall': 24.88}\n",
    "Func worker, run time: 0.3048582077026367\n",
    "Func splitData, run time: 1.0542120933532715\n",
    "Experiment 2:\n",
    "Metric: {'Precision': 3.18, 'Recall': 24.69}\n",
    "Func worker, run time: 0.29949402809143066\n",
    "Func splitData, run time: 0.9658150672912598\n",
    "Experiment 3:\n",
    "Metric: {'Precision': 3.19, 'Recall': 24.84}\n",
    "Func worker, run time: 0.4243886470794678\n",
    "Func splitData, run time: 0.962958812713623\n",
    "Experiment 4:\n",
    "Metric: {'Precision': 3.17, 'Recall': 24.79}\n",
    "Func worker, run time: 0.4475588798522949\n",
    "Func splitData, run time: 0.9121999740600586\n",
    "Experiment 5:\n",
    "Metric: {'Precision': 3.12, 'Recall': 24.33}\n",
    "Func worker, run time: 0.46161675453186035\n",
    "Func splitData, run time: 0.9740099906921387\n",
    "Experiment 6:\n",
    "Metric: {'Precision': 3.17, 'Recall': 24.74}\n",
    "Func worker, run time: 0.4318516254425049\n",
    "Func splitData, run time: 0.8616311550140381\n",
    "Experiment 7:\n",
    "Metric: {'Precision': 3.13, 'Recall': 24.43}\n",
    "Func worker, run time: 0.4322950839996338\n",
    "Func splitData, run time: 0.8580801486968994\n",
    "Experiment 8:\n",
    "Metric: {'Precision': 3.17, 'Recall': 24.65}\n",
    "Func worker, run time: 0.42772817611694336\n",
    "Func splitData, run time: 0.8563971519470215\n",
    "Experiment 9:\n",
    "Metric: {'Precision': 3.17, 'Recall': 24.64}\n",
    "Func worker, run time: 0.43137383460998535\n",
    "Average Result (M=10, N=10): {'Precision': 3.1689999999999996, 'Recall': 24.695000000000004}\n",
    "Func run, run time: 14.44516921043396\n",
    "\n",
    "3. ItemPopular实验\n",
    "Func loadData, run time: 0.555941104888916\n",
    "Func splitData, run time: 1.1046972274780273\n",
    "Experiment 0:\n",
    "Metric: {'Precision': 1.67, 'Recall': 8.19}\n",
    "Func worker, run time: 0.7694768905639648\n",
    "Func splitData, run time: 0.9527928829193115\n",
    "Experiment 1:\n",
    "Metric: {'Precision': 1.57, 'Recall': 7.66}\n",
    "Func worker, run time: 0.7398290634155273\n",
    "Func splitData, run time: 0.9173603057861328\n",
    "Experiment 2:\n",
    "Metric: {'Precision': 1.62, 'Recall': 7.9}\n",
    "Func worker, run time: 0.655925989151001\n",
    "Func splitData, run time: 1.093824863433838\n",
    "Experiment 3:\n",
    "Metric: {'Precision': 1.6, 'Recall': 7.77}\n",
    "Func worker, run time: 0.49861979484558105\n",
    "Func splitData, run time: 1.1611483097076416\n",
    "Experiment 4:\n",
    "Metric: {'Precision': 1.63, 'Recall': 7.97}\n",
    "Func worker, run time: 0.5834429264068604\n",
    "Func splitData, run time: 1.0758311748504639\n",
    "Experiment 5:\n",
    "Metric: {'Precision': 1.62, 'Recall': 7.95}\n",
    "Func worker, run time: 0.5447440147399902\n",
    "Func splitData, run time: 1.1658220291137695\n",
    "Experiment 6:\n",
    "Metric: {'Precision': 1.62, 'Recall': 7.92}\n",
    "Func worker, run time: 0.570044994354248\n",
    "Func splitData, run time: 1.09977388381958\n",
    "Experiment 7:\n",
    "Metric: {'Precision': 1.61, 'Recall': 7.88}\n",
    "Func worker, run time: 0.5018339157104492\n",
    "Func splitData, run time: 1.0852570533752441\n",
    "Experiment 8:\n",
    "Metric: {'Precision': 1.61, 'Recall': 7.83}\n",
    "Func worker, run time: 0.5137588977813721\n",
    "Func splitData, run time: 1.1302859783172607\n",
    "Experiment 9:\n",
    "Metric: {'Precision': 1.59, 'Recall': 7.74}\n",
    "Func worker, run time: 0.6344318389892578\n",
    "Average Result (M=10, N=10): {'Precision': 1.614, 'Recall': 7.881}\n",
    "Func run, run time: 17.594825983047485\n",
    "\n",
    "4. HybridPopular实验\n",
    "alpha = 0.0\n",
    "Func loadData, run time: 0.8270349502563477\n",
    "Func splitData, run time: 1.1357169151306152\n",
    "Experiment 0:\n",
    "Metric: {'Precision': 3.2, 'Recall': 24.98}\n",
    "Func worker, run time: 3.6687381267547607\n",
    "Func splitData, run time: 1.313784122467041\n",
    "Experiment 1:\n",
    "Metric: {'Precision': 3.19, 'Recall': 24.89}\n",
    "Func worker, run time: 3.9108307361602783\n",
    "Func splitData, run time: 1.080482006072998\n",
    "Experiment 2:\n",
    "Metric: {'Precision': 3.17, 'Recall': 24.7}\n",
    "Func worker, run time: 3.9596028327941895\n",
    "Func splitData, run time: 1.113774061203003\n",
    "Experiment 3:\n",
    "Metric: {'Precision': 3.19, 'Recall': 24.86}\n",
    "Func worker, run time: 3.9999098777770996\n",
    "Func splitData, run time: 1.1503219604492188\n",
    "Experiment 4:\n",
    "Metric: {'Precision': 3.17, 'Recall': 24.8}\n",
    "Func worker, run time: 3.866776943206787\n",
    "Func splitData, run time: 0.9508001804351807\n",
    "Experiment 5:\n",
    "Metric: {'Precision': 3.12, 'Recall': 24.35}\n",
    "Func worker, run time: 4.116667985916138\n",
    "Func splitData, run time: 0.9126389026641846\n",
    "Experiment 6:\n",
    "Metric: {'Precision': 3.16, 'Recall': 24.75}\n",
    "Func worker, run time: 4.2959370613098145\n",
    "Func splitData, run time: 0.9400320053100586\n",
    "Experiment 7:\n",
    "Metric: {'Precision': 3.13, 'Recall': 24.45}\n",
    "Func worker, run time: 4.016885042190552\n",
    "Func splitData, run time: 0.9569549560546875\n",
    "Experiment 8:\n",
    "Metric: {'Precision': 3.16, 'Recall': 24.66}\n",
    "Func worker, run time: 4.140321969985962\n",
    "Func splitData, run time: 0.9315330982208252\n",
    "Experiment 9:\n",
    "Metric: {'Precision': 3.17, 'Recall': 24.66}\n",
    "Func worker, run time: 3.96396803855896\n",
    "Average Result (M=10, N=10): {'Precision': 3.1659999999999995, 'Recall': 24.71}\n",
    "Func run, run time: 51.46743392944336\n",
    "alpha = 0.1\n",
    "Func loadData, run time: 0.5897848606109619\n",
    "Func splitData, run time: 1.2940878868103027\n",
    "Experiment 0:\n",
    "Metric: {'Precision': 3.16, 'Recall': 24.71}\n",
    "Func worker, run time: 4.220802068710327\n",
    "Func splitData, run time: 1.119277000427246\n",
    "Experiment 1:\n",
    "Metric: {'Precision': 3.16, 'Recall': 24.67}\n",
    "Func worker, run time: 3.690171003341675\n",
    "Func splitData, run time: 1.1244220733642578\n",
    "Experiment 2:\n",
    "Metric: {'Precision': 3.15, 'Recall': 24.52}\n",
    "Func worker, run time: 3.741908073425293\n",
    "Func splitData, run time: 1.0858471393585205\n",
    "Experiment 3:\n",
    "Metric: {'Precision': 3.15, 'Recall': 24.57}\n",
    "Func worker, run time: 3.828856945037842\n",
    "Func splitData, run time: 0.9331462383270264\n",
    "Experiment 4:\n",
    "Metric: {'Precision': 3.15, 'Recall': 24.68}\n",
    "Func worker, run time: 3.770294189453125\n",
    "Func splitData, run time: 0.881289005279541\n",
    "Experiment 5:\n",
    "Metric: {'Precision': 3.09, 'Recall': 24.13}\n",
    "Func worker, run time: 3.8148388862609863\n",
    "Func splitData, run time: 0.9065887928009033\n",
    "Experiment 6:\n",
    "Metric: {'Precision': 3.13, 'Recall': 24.52}\n",
    "Func worker, run time: 3.847368001937866\n",
    "Func splitData, run time: 0.8994863033294678\n",
    "Experiment 7:\n",
    "Metric: {'Precision': 3.09, 'Recall': 24.18}\n",
    "Func worker, run time: 3.8750672340393066\n",
    "Func splitData, run time: 0.9352071285247803\n",
    "Experiment 8:\n",
    "Metric: {'Precision': 3.14, 'Recall': 24.45}\n",
    "Func worker, run time: 3.980964183807373\n",
    "Func splitData, run time: 0.8821008205413818\n",
    "Experiment 9:\n",
    "Metric: {'Precision': 3.13, 'Recall': 24.37}\n",
    "Func worker, run time: 3.780784845352173\n",
    "Average Result (M=10, N=10): {'Precision': 3.135, 'Recall': 24.48}\n",
    "Func run, run time: 49.395665884017944\n",
    "alpha = 0.2\n",
    "Func loadData, run time: 0.5564239025115967\n",
    "Func splitData, run time: 1.0819451808929443\n",
    "Experiment 0:\n",
    "Metric: {'Precision': 3.09, 'Recall': 24.13}\n",
    "Func worker, run time: 3.7844419479370117\n",
    "Func splitData, run time: 1.1305460929870605\n",
    "Experiment 1:\n",
    "Metric: {'Precision': 3.08, 'Recall': 24.05}\n",
    "Func worker, run time: 3.8170173168182373\n",
    "Func splitData, run time: 0.8823709487915039\n",
    "Experiment 2:\n",
    "Metric: {'Precision': 3.07, 'Recall': 23.88}\n",
    "Func worker, run time: 3.8645858764648438\n",
    "Func splitData, run time: 0.926703929901123\n",
    "Experiment 3:\n",
    "Metric: {'Precision': 3.06, 'Recall': 23.85}\n",
    "Func worker, run time: 3.8203530311584473\n",
    "Func splitData, run time: 0.8779711723327637\n",
    "Experiment 4:\n",
    "Metric: {'Precision': 3.07, 'Recall': 24.07}\n",
    "Func worker, run time: 4.0470640659332275\n",
    "Func splitData, run time: 0.8845350742340088\n",
    "Experiment 5:\n",
    "Metric: {'Precision': 3.04, 'Recall': 23.76}\n",
    "Func worker, run time: 3.8835208415985107\n",
    "Func splitData, run time: 0.8999407291412354\n",
    "Experiment 6:\n",
    "Metric: {'Precision': 3.06, 'Recall': 23.94}\n",
    "Func worker, run time: 3.8781838417053223\n",
    "Func splitData, run time: 0.8658223152160645\n",
    "Experiment 7:\n",
    "Metric: {'Precision': 3.02, 'Recall': 23.59}\n",
    "Func worker, run time: 3.9182791709899902\n",
    "Func splitData, run time: 0.8931410312652588\n",
    "Experiment 8:\n",
    "Metric: {'Precision': 3.06, 'Recall': 23.88}\n",
    "Func worker, run time: 3.91605281829834\n",
    "Func splitData, run time: 0.9485352039337158\n",
    "Experiment 9:\n",
    "Metric: {'Precision': 3.05, 'Recall': 23.75}\n",
    "Func worker, run time: 3.9514670372009277\n",
    "Average Result (M=10, N=10): {'Precision': 3.0599999999999996, 'Recall': 23.889999999999997}\n",
    "Func run, run time: 49.03358316421509\n",
    "alpha = 0.3\n",
    "Func loadData, run time: 0.8165087699890137\n",
    "Func splitData, run time: 1.1548380851745605\n",
    "Experiment 0:\n",
    "Metric: {'Precision': 2.99, 'Recall': 23.33}\n",
    "Func worker, run time: 3.9186530113220215\n",
    "Func splitData, run time: 1.1145899295806885\n",
    "Experiment 1:\n",
    "Metric: {'Precision': 2.98, 'Recall': 23.23}\n",
    "Func worker, run time: 3.880518913269043\n",
    "Func splitData, run time: 0.9590201377868652\n",
    "Experiment 2:\n",
    "Metric: {'Precision': 2.98, 'Recall': 23.18}\n",
    "Func worker, run time: 4.014327049255371\n",
    "Func splitData, run time: 0.9428629875183105\n",
    "Experiment 3:\n",
    "Metric: {'Precision': 2.96, 'Recall': 23.07}\n",
    "Func worker, run time: 4.099957704544067\n",
    "Func splitData, run time: 0.945389986038208\n",
    "Experiment 4:\n",
    "Metric: {'Precision': 2.98, 'Recall': 23.37}\n",
    "Func worker, run time: 3.903257131576538\n",
    "Func splitData, run time: 0.8871619701385498\n",
    "Experiment 5:\n",
    "Metric: {'Precision': 2.95, 'Recall': 23.01}\n",
    "Func worker, run time: 4.016380310058594\n",
    "Func splitData, run time: 0.9477517604827881\n",
    "Experiment 6:\n",
    "Metric: {'Precision': 2.97, 'Recall': 23.2}\n",
    "Func worker, run time: 4.101273059844971\n",
    "Func splitData, run time: 0.9239673614501953\n",
    "Experiment 7:\n",
    "Metric: {'Precision': 2.93, 'Recall': 22.92}\n",
    "Func worker, run time: 4.01638388633728\n",
    "Func splitData, run time: 1.129809856414795\n",
    "Experiment 8:\n",
    "Metric: {'Precision': 2.97, 'Recall': 23.17}\n",
    "Func worker, run time: 4.296221971511841\n",
    "Func splitData, run time: 1.0508511066436768\n",
    "Experiment 9:\n",
    "Metric: {'Precision': 2.96, 'Recall': 23.06}\n",
    "Func worker, run time: 4.31338906288147\n",
    "Average Result (M=10, N=10): {'Precision': 2.9669999999999996, 'Recall': 23.154000000000003}\n",
    "Func run, run time: 51.64158391952515\n",
    "alpha = 0.4\n",
    "Func loadData, run time: 0.5854520797729492\n",
    "Func splitData, run time: 1.2064447402954102\n",
    "Experiment 0:\n",
    "Metric: {'Precision': 2.9, 'Recall': 22.66}\n",
    "Func worker, run time: 3.82174015045166\n",
    "Func splitData, run time: 1.109299898147583\n",
    "Experiment 1:\n",
    "Metric: {'Precision': 2.89, 'Recall': 22.59}\n",
    "Func worker, run time: 3.7054030895233154\n",
    "Func splitData, run time: 1.0969369411468506\n",
    "Experiment 2:\n",
    "Metric: {'Precision': 2.9, 'Recall': 22.58}\n",
    "Func worker, run time: 3.6588618755340576\n",
    "Func splitData, run time: 1.0210728645324707\n",
    "Experiment 3:\n",
    "Metric: {'Precision': 2.88, 'Recall': 22.49}\n",
    "Func worker, run time: 4.334802150726318\n",
    "Func splitData, run time: 0.9911270141601562\n",
    "Experiment 4:\n",
    "Metric: {'Precision': 2.89, 'Recall': 22.63}\n",
    "Func worker, run time: 3.9276959896087646\n",
    "Func splitData, run time: 0.8923721313476562\n",
    "Experiment 5:\n",
    "Metric: {'Precision': 2.88, 'Recall': 22.5}\n",
    "Func worker, run time: 3.918529987335205\n",
    "Func splitData, run time: 0.8772850036621094\n",
    "Experiment 6:\n",
    "Metric: {'Precision': 2.89, 'Recall': 22.64}\n",
    "Func worker, run time: 4.415400981903076\n",
    "Func splitData, run time: 0.9515841007232666\n",
    "Experiment 7:\n",
    "Metric: {'Precision': 2.86, 'Recall': 22.31}\n",
    "Func worker, run time: 3.962172269821167\n",
    "Func splitData, run time: 0.9239819049835205\n",
    "Experiment 8:\n",
    "Metric: {'Precision': 2.89, 'Recall': 22.53}\n",
    "Func worker, run time: 4.088367938995361\n",
    "Func splitData, run time: 0.9344871044158936\n",
    "Experiment 9:\n",
    "Metric: {'Precision': 2.89, 'Recall': 22.48}\n",
    "Func worker, run time: 4.000338077545166\n",
    "Average Result (M=10, N=10): {'Precision': 2.887, 'Recall': 22.540999999999997}\n",
    "Func run, run time: 50.62652516365051\n",
    "alpha = 0.5\n",
    "Func loadData, run time: 0.6036858558654785\n",
    "Func splitData, run time: 1.1832058429718018\n",
    "Experiment 0:\n",
    "Metric: {'Precision': 2.83, 'Recall': 22.12}\n",
    "Func worker, run time: 3.846303939819336\n",
    "Func splitData, run time: 1.1365282535552979\n",
    "Experiment 1:\n",
    "Metric: {'Precision': 2.82, 'Recall': 21.99}\n",
    "Func worker, run time: 3.859900951385498\n",
    "Func splitData, run time: 0.9495680332183838\n",
    "Experiment 2:\n",
    "Metric: {'Precision': 2.83, 'Recall': 22.04}\n",
    "Func worker, run time: 4.079281806945801\n",
    "Func splitData, run time: 0.9861047267913818\n",
    "Experiment 3:\n",
    "Metric: {'Precision': 2.83, 'Recall': 22.06}\n",
    "Func worker, run time: 4.394114017486572\n",
    "Func splitData, run time: 1.0009009838104248\n",
    "Experiment 4:\n",
    "Metric: {'Precision': 2.82, 'Recall': 22.1}\n",
    "Func worker, run time: 4.027346134185791\n",
    "Func splitData, run time: 0.8993139266967773\n",
    "Experiment 5:\n",
    "Metric: {'Precision': 2.81, 'Recall': 21.98}\n",
    "Func worker, run time: 4.053209066390991\n",
    "Func splitData, run time: 0.9647109508514404\n",
    "Experiment 6:\n",
    "Metric: {'Precision': 2.83, 'Recall': 22.13}\n",
    "Func worker, run time: 4.376596927642822\n",
    "Func splitData, run time: 1.0014677047729492\n",
    "Experiment 7:\n",
    "Metric: {'Precision': 2.78, 'Recall': 21.74}\n",
    "Func worker, run time: 4.266858816146851\n",
    "Func splitData, run time: 0.924774169921875\n",
    "Experiment 8:\n",
    "Metric: {'Precision': 2.81, 'Recall': 21.9}\n",
    "Func worker, run time: 3.9737420082092285\n",
    "Func splitData, run time: 0.8944978713989258\n",
    "Experiment 9:\n",
    "Metric: {'Precision': 2.82, 'Recall': 21.92}\n",
    "Func worker, run time: 3.682781934738159\n",
    "Average Result (M=10, N=10): {'Precision': 2.8180000000000005, 'Recall': 21.998}\n",
    "Func run, run time: 51.33020997047424\n",
    "alpha = 0.6\n",
    "Func loadData, run time: 0.7814671993255615\n",
    "Func splitData, run time: 1.1311962604522705\n",
    "Experiment 0:\n",
    "Metric: {'Precision': 2.81, 'Recall': 21.99}\n",
    "Func worker, run time: 3.6779329776763916\n",
    "Func splitData, run time: 1.0877008438110352\n",
    "Experiment 1:\n",
    "Metric: {'Precision': 2.8, 'Recall': 21.87}\n",
    "Func worker, run time: 3.7011940479278564\n",
    "Func splitData, run time: 0.931542158126831\n",
    "Experiment 2:\n",
    "Metric: {'Precision': 2.83, 'Recall': 22.02}\n",
    "Func worker, run time: 4.184109926223755\n",
    "Func splitData, run time: 0.9873087406158447\n",
    "Experiment 3:\n",
    "Metric: {'Precision': 2.81, 'Recall': 21.95}\n",
    "Func worker, run time: 4.34235692024231\n",
    "Func splitData, run time: 0.9976329803466797\n",
    "Experiment 4:\n",
    "Metric: {'Precision': 2.81, 'Recall': 21.99}\n",
    "Func worker, run time: 4.107128858566284\n",
    "Func splitData, run time: 1.0260448455810547\n",
    "Experiment 5:\n",
    "Metric: {'Precision': 2.8, 'Recall': 21.87}\n",
    "Func worker, run time: 4.346803903579712\n",
    "Func splitData, run time: 0.9875109195709229\n",
    "Experiment 6:\n",
    "Metric: {'Precision': 2.81, 'Recall': 21.97}\n",
    "Func worker, run time: 4.095118045806885\n",
    "Func splitData, run time: 0.954246997833252\n",
    "Experiment 7:\n",
    "Metric: {'Precision': 2.77, 'Recall': 21.64}\n",
    "Func worker, run time: 4.133518934249878\n",
    "Func splitData, run time: 0.9359958171844482\n",
    "Experiment 8:\n",
    "Metric: {'Precision': 2.79, 'Recall': 21.78}\n",
    "Func worker, run time: 4.088289976119995\n",
    "Func splitData, run time: 0.9729337692260742\n",
    "Experiment 9:\n",
    "Metric: {'Precision': 2.8, 'Recall': 21.83}\n",
    "Func worker, run time: 4.133095979690552\n",
    "Average Result (M=10, N=10): {'Precision': 2.803, 'Recall': 21.891000000000002}\n",
    "Func run, run time: 51.847046852111816\n",
    "alpha = 0.7\n",
    "Func loadData, run time: 0.6439578533172607\n",
    "Func splitData, run time: 1.2230210304260254\n",
    "Experiment 0:\n",
    "Metric: {'Precision': 2.8, 'Recall': 21.87}\n",
    "Func worker, run time: 3.8913540840148926\n",
    "Func splitData, run time: 1.1245911121368408\n",
    "Experiment 1:\n",
    "Metric: {'Precision': 2.79, 'Recall': 21.81}\n",
    "Func worker, run time: 3.9031801223754883\n",
    "Func splitData, run time: 1.241105079650879\n",
    "Experiment 2:\n",
    "Metric: {'Precision': 2.81, 'Recall': 21.87}\n",
    "Func worker, run time: 3.9086101055145264\n",
    "Func splitData, run time: 0.9072818756103516\n",
    "Experiment 3:\n",
    "Metric: {'Precision': 2.79, 'Recall': 21.74}\n",
    "Func worker, run time: 4.126950740814209\n",
    "Func splitData, run time: 0.9839358329772949\n",
    "Experiment 4:\n",
    "Metric: {'Precision': 2.79, 'Recall': 21.85}\n",
    "Func worker, run time: 4.147830009460449\n",
    "Func splitData, run time: 0.9406859874725342\n",
    "Experiment 5:\n",
    "Metric: {'Precision': 2.8, 'Recall': 21.84}\n",
    "Func worker, run time: 4.09603214263916\n",
    "Func splitData, run time: 0.9855873584747314\n",
    "Experiment 6:\n",
    "Metric: {'Precision': 2.79, 'Recall': 21.83}\n",
    "Func worker, run time: 4.132368326187134\n",
    "Func splitData, run time: 0.9442930221557617\n",
    "Experiment 7:\n",
    "Metric: {'Precision': 2.77, 'Recall': 21.61}\n",
    "Func worker, run time: 4.14454984664917\n",
    "Func splitData, run time: 0.9878599643707275\n",
    "Experiment 8:\n",
    "Metric: {'Precision': 2.78, 'Recall': 21.67}\n",
    "Func worker, run time: 4.150234937667847\n",
    "Func splitData, run time: 0.9582130908966064\n",
    "Experiment 9:\n",
    "Metric: {'Precision': 2.79, 'Recall': 21.75}\n",
    "Func worker, run time: 4.084574937820435\n",
    "Average Result (M=10, N=10): {'Precision': 2.791, 'Recall': 21.784000000000002}\n",
    "Func run, run time: 51.78817391395569\n",
    "alpha = 0.8\n",
    "Func loadData, run time: 0.6539361476898193\n",
    "Func splitData, run time: 1.23051118850708\n",
    "Experiment 0:\n",
    "Metric: {'Precision': 2.79, 'Recall': 21.8}\n",
    "Func worker, run time: 3.9864609241485596\n",
    "Func splitData, run time: 1.1422462463378906\n",
    "Experiment 1:\n",
    "Metric: {'Precision': 2.78, 'Recall': 21.71}\n",
    "Func worker, run time: 3.915750026702881\n",
    "Func splitData, run time: 0.9693622589111328\n",
    "Experiment 2:\n",
    "Metric: {'Precision': 2.8, 'Recall': 21.79}\n",
    "Func worker, run time: 4.121142148971558\n",
    "Func splitData, run time: 0.9255979061126709\n",
    "Experiment 3:\n",
    "Metric: {'Precision': 2.78, 'Recall': 21.69}\n",
    "Func worker, run time: 4.081761598587036\n",
    "Func splitData, run time: 0.9528212547302246\n",
    "Experiment 4:\n",
    "Metric: {'Precision': 2.78, 'Recall': 21.77}\n",
    "Func worker, run time: 4.107932090759277\n",
    "Func splitData, run time: 0.9039068222045898\n",
    "Experiment 5:\n",
    "Metric: {'Precision': 2.79, 'Recall': 21.77}\n",
    "Func worker, run time: 4.103371858596802\n",
    "Func splitData, run time: 0.9776840209960938\n",
    "Experiment 6:\n",
    "Metric: {'Precision': 2.78, 'Recall': 21.77}\n",
    "Func worker, run time: 4.158017873764038\n",
    "Func splitData, run time: 0.9379229545593262\n",
    "Experiment 7:\n",
    "Metric: {'Precision': 2.76, 'Recall': 21.54}\n",
    "Func worker, run time: 4.1544189453125\n",
    "Func splitData, run time: 0.9832949638366699\n",
    "Experiment 8:\n",
    "Metric: {'Precision': 2.76, 'Recall': 21.55}\n",
    "Func worker, run time: 4.169132947921753\n",
    "Func splitData, run time: 0.9408540725708008\n",
    "Experiment 9:\n",
    "Metric: {'Precision': 2.78, 'Recall': 21.68}\n",
    "Func worker, run time: 3.8871219158172607\n",
    "Average Result (M=10, N=10): {'Precision': 2.78, 'Recall': 21.707}\n",
    "Func run, run time: 51.54830598831177\n",
    "alpha = 0.9\n",
    "Func loadData, run time: 1.0025537014007568\n",
    "Func splitData, run time: 1.333798885345459\n",
    "Experiment 0:\n",
    "Metric: {'Precision': 2.78, 'Recall': 21.72}\n",
    "Func worker, run time: 4.1268157958984375\n",
    "Func splitData, run time: 1.2158279418945312\n",
    "Experiment 1:\n",
    "Metric: {'Precision': 2.77, 'Recall': 21.64}\n",
    "Func worker, run time: 4.124691963195801\n",
    "Func splitData, run time: 0.9392058849334717\n",
    "Experiment 2:\n",
    "Metric: {'Precision': 2.79, 'Recall': 21.73}\n",
    "Func worker, run time: 4.153153896331787\n",
    "Func splitData, run time: 1.040349006652832\n",
    "Experiment 3:\n",
    "Metric: {'Precision': 2.78, 'Recall': 21.65}\n",
    "Func worker, run time: 4.2734057903289795\n",
    "Func splitData, run time: 0.9350490570068359\n",
    "Experiment 4:\n",
    "Metric: {'Precision': 2.77, 'Recall': 21.74}\n",
    "Func worker, run time: 4.1106908321380615\n",
    "Func splitData, run time: 0.9704811573028564\n",
    "Experiment 5:\n",
    "Metric: {'Precision': 2.78, 'Recall': 21.74}\n",
    "Func worker, run time: 4.073996067047119\n",
    "Func splitData, run time: 0.9093971252441406\n",
    "Experiment 6:\n",
    "Metric: {'Precision': 2.78, 'Recall': 21.71}\n",
    "Func worker, run time: 4.173330783843994\n",
    "Func splitData, run time: 0.950319766998291\n",
    "Experiment 7:\n",
    "Metric: {'Precision': 2.75, 'Recall': 21.5}\n",
    "Func worker, run time: 4.211034059524536\n",
    "Func splitData, run time: 0.9746339321136475\n",
    "Experiment 8:\n",
    "Metric: {'Precision': 2.76, 'Recall': 21.51}\n",
    "Func worker, run time: 4.386167049407959\n",
    "Func splitData, run time: 1.059217929840088\n",
    "Experiment 9:\n",
    "Metric: {'Precision': 2.78, 'Recall': 21.63}\n",
    "Func worker, run time: 4.3950629234313965\n",
    "Average Result (M=10, N=10): {'Precision': 2.774, 'Recall': 21.657}\n",
    "Func run, run time: 53.61407208442688\n",
    "alpha = 1.0\n",
    "Func loadData, run time: 0.759735107421875\n",
    "Func splitData, run time: 1.224877119064331\n",
    "Experiment 0:\n",
    "Metric: {'Precision': 1.82, 'Recall': 14.18}\n",
    "Func worker, run time: 3.729387044906616\n",
    "Func splitData, run time: 1.0924749374389648\n",
    "Experiment 1:\n",
    "Metric: {'Precision': 1.8, 'Recall': 14.09}\n",
    "Func worker, run time: 3.4529192447662354\n",
    "Func splitData, run time: 1.1971077919006348\n",
    "Experiment 2:\n",
    "Metric: {'Precision': 1.82, 'Recall': 14.17}\n",
    "Func worker, run time: 3.3798270225524902\n",
    "Func splitData, run time: 0.9837942123413086\n",
    "Experiment 3:\n",
    "Metric: {'Precision': 1.79, 'Recall': 13.97}\n",
    "Func worker, run time: 3.9176063537597656\n",
    "Func splitData, run time: 0.9464359283447266\n",
    "Experiment 4:\n",
    "Metric: {'Precision': 1.8, 'Recall': 14.13}\n",
    "Func worker, run time: 3.7294299602508545\n",
    "Func splitData, run time: 0.9589240550994873\n",
    "Experiment 5:\n",
    "Metric: {'Precision': 1.81, 'Recall': 14.16}\n",
    "Func worker, run time: 3.68717098236084\n",
    "Func splitData, run time: 0.9121508598327637\n",
    "Experiment 6:\n",
    "Metric: {'Precision': 1.82, 'Recall': 14.22}\n",
    "Func worker, run time: 3.720194101333618\n",
    "Func splitData, run time: 0.9417569637298584\n",
    "Experiment 7:\n",
    "Metric: {'Precision': 1.8, 'Recall': 14.05}\n",
    "Func worker, run time: 3.7353739738464355\n",
    "Func splitData, run time: 0.9648470878601074\n",
    "Experiment 8:\n",
    "Metric: {'Precision': 1.78, 'Recall': 13.9}\n",
    "Func worker, run time: 3.7211191654205322\n",
    "Func splitData, run time: 0.9093520641326904\n",
    "Experiment 9:\n",
    "Metric: {'Precision': 1.81, 'Recall': 14.08}\n",
    "Func worker, run time: 3.725862979888916\n",
    "Average Result (M=10, N=10): {'Precision': 1.8050000000000002, 'Recall': 14.094999999999999}\n",
    "Func run, run time: 47.9080491065979"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
